Add GET /lookups/ranges endpoint for lookup range brackets#7
Add GET /lookups/ranges endpoint for lookup range brackets#7gsayer wants to merge 1 commit intoPayroll-Engine:mainfrom
Conversation
… with computed upper bounds
Added LookupRangeBracket and LookupRangeResult POCOs, BuildRangeBrackets extension method on LookupSet, API DTOs, Mapperly mappers, and payroll controller endpoint at {payrollId}/lookups/ranges supporting threshold and progressive range modes with optional range value matching. Updated swagger.json with new path and component schemas.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2a07b3b to
8fd72be
Compare
|
@gsayer Thank you for this useful extension. There are two conceptual points that we should consider: Closed value rangesCurrently, the ActionChange the value of Unique lookup bracketThe result should be that I get one bracket for each range value only. Currently, the ActionThe var precision = (decimal)Math.Pow(10, -SystemSpecification.DecimalScale);
currentBracket.UpperBound = nextBracket.LowerBound - precision; |
|
Hi @Giannoudis 👋 After further work on my regulation layer, I found a more elegant approach that makes this endpoint unnecessary for my use case. Instead of exposing lookup range brackets through a dedicated API endpoint, I solved the underlying need (contribution catalogue without running a payrun) by:
This means I can retrieve the full contribution structure (rates, ceilings, categories) by simply calling the existing GET /payrolls/{id}/wagetypes endpoint and reading the attributes (no new backend endpoint needed). I don't think this PR is useful anymore, what do you think? Thank you for reviewing it, and apologies for the noise! |
Summary
GET /api/tenants/{tenantId}/payrolls/{payrollId}/lookups/rangesendpoint that returns lookup range brackets with computed upper boundsLookupSetExtensionsbut previously not accessible via the APIMotivation
Current lookup endpoints return either raw values (without computed bounds) or a single matched value. There is no way to retrieve the complete bracket structure (lower + upper bounds) through the API. This is needed for contribution preview in salary simulation case (For example, giving visibility of the social contribution threshold based on employee cases).
New endpoint
Returns
LookupRangeResult[]withallBrackets,matchingBracket(threshold),matchingBrackets(progressive).Changes
LookupRangeBracket.cs,LookupRangeResult.cs,LookupSetExtensions.csBuildRangeBrackets()methodLookupRangeBracket.cs,LookupRangeResult.csLookupRangeBracketMap.cs,LookupRangeResultMap.csPayrollController.csPayrollController.cs[HttpGet("{payrollId}/lookups/ranges")]Test plan
dotnet buildpasses with TreatWarningsAsErrorsdotnet testpassesmatchingBracketreturned for a givenrangeValuematchingBracketsreturnedrangeSizefor last bracket)lookupNames